package com.jinghong.registerlogin.mapper;

import com.jinghong.registerlogin.model.pojo.Paper;
import com.jinghong.registerlogin.model.pojo.PaperQuestion;
import com.jinghong.registerlogin.model.pojo.Question;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * ClassName:paperQuestionMapper
 * Package:com.jinghong.registerlogin.mapper
 * Description:
 *
 * @Author: 寻月君子
 * @CreatTime:2024/5/25 21:23
 * Version:1.0
 */
@Mapper
public interface PaperQuestionMapper {
    //增

    /**
     * 新增试卷与问题的关联
     * @param paperQuestion 试卷与问题的关联
     */
    @Insert("insert into `register_login`.paper_question(paper_id, question_id) VALUES (#{paperId},#{questionId})")
    void insert(PaperQuestion paperQuestion);


    /**
     * 批量新增试卷与问题的关联
     * @param paperQuestions 试卷与问题的关联集合
     */
    void bulkInsert(List<PaperQuestion> paperQuestions);


    //删

    /**
     * 删除试卷
     * @param id 问题关联的试卷ids
     */
    @Delete("delete  from `register_login`.paper_question where paper_id = #{paperId}")
    void deleteByPaperId(Integer id);


    //改


    //查

    /**
     * 条件搜索
     * @param paperId
     * @return 试卷集合
     */
    @Select("select * from `register_login`.paper_question where paper_id = #{paperId}")
    List<Paper> select(Integer paperId);


    /**
     * 编辑试卷时数据回显
     * @param id id
     * @return paper
     */
    @Select("select * from `register_login`.paper_question where id = #{id}")
    Paper getById(Integer id);


    @Select("select * from `register_login`.paper_question where paper_id = #{id}")
    List<PaperQuestion> getByPaperId(Integer id);

    void bulkDelete(Integer paperId, List<Integer> questionIds);
}
